import 'package:equatable/equatable.dart';
import 'package:backend.core/core/domain/entities/api/google_play/api_google_play_purchased_subscription_transaction_offer_type.dart';

const kApiGooglePlayPurchasedSubscriptionTransactionTrialPeriodOfferTypeValue = 'trial_period';
const kApiGooglePlayPurchasedSubscriptionTransactionPromotionalOfferTypeValue = 'promotional';
const kApiGooglePlayPurchasedSubscriptionTransactionRegularOfferTypeValue = 'regular';

class ApiGooglePlayPurchasedSubscriptionTransactionOfferTypeDto extends Equatable {
  const ApiGooglePlayPurchasedSubscriptionTransactionOfferTypeDto._internal({
    required this.offerTypeString,
  });

  final String offerTypeString;

  @override
  List<Object?> get props {
    return [
      offerTypeString,
    ];
  }

  factory ApiGooglePlayPurchasedSubscriptionTransactionOfferTypeDto.fromEntity(
      ApiGooglePlayPurchasedSubscriptionTransactionOfferType offerType) {
    late final String offerTypeString;

    if (offerType == ApiGooglePlayPurchasedSubscriptionTransactionOfferType.trialPeriod) {
      offerTypeString = kApiGooglePlayPurchasedSubscriptionTransactionTrialPeriodOfferTypeValue;
    } else if (offerType == ApiGooglePlayPurchasedSubscriptionTransactionOfferType.promotional) {
      offerTypeString = kApiGooglePlayPurchasedSubscriptionTransactionPromotionalOfferTypeValue;
    } else if (offerType == ApiGooglePlayPurchasedSubscriptionTransactionOfferType.regular) {
      offerTypeString = kApiGooglePlayPurchasedSubscriptionTransactionRegularOfferTypeValue;
    }

    return ApiGooglePlayPurchasedSubscriptionTransactionOfferTypeDto._internal(
      offerTypeString: offerTypeString,
    );
  }

  @override
  String toString() {
    return offerTypeString;
  }
}
